/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fiad.gui.components;

import java.util.GregorianCalendar;
import javax.swing.AbstractSpinnerModel;

/**
 *
 * @author MJ
 */
public class MySpinnerModel extends AbstractSpinnerModel {

    private static int currentValue = 0;
    private Object displayValue;

    public MySpinnerModel() {
        super();
        currentValue = new GregorianCalendar().get(GregorianCalendar.YEAR);
        updateDisplayValue();
    }

    @Override
    public Object getValue() {
        return displayValue;
    }

    @Override
    public Object getNextValue() {
        currentValue += 1;
        updateDisplayValue();
        return displayValue;
    }

    @Override
    public Object getPreviousValue() {
        currentValue -= 1;
        updateDisplayValue();
        return displayValue;

    }

    private void updateDisplayValue() {
        displayValue = currentValue + "/" + (currentValue + 1);
    }

    public void setValue(Object value) {
        displayValue = value;
        fireStateChanged();
    }
}
